/**
 * 队列工具库
 */
let runMap = {}

/**
 * 适用于不确认有多少异步需要执行的情况
 */
type callBackType = (resolve:((value: unknown) => void),res:any) => void
export const addRun = function (callBack:callBackType,key = 'default') {
    if (!runMap[key]) {
        runMap[key] = Promise.resolve()
    }
    runMap[key] = runMap[key].then((res) => new Promise(resolve => {
        callBack(resolve,res)
    }))
}
export default {
    addRun
}
